package org.example.struct.array2;

/**
 * @author liyishan
 * @date 2024/9/9 13:38
 * @apiNote
 */

public class Test01343NumOfSubarrays {

    public int numOfSubarrays(int[] arr, int k, int threshold) {
        int temp = k * threshold;
        int sum = 0;
        int count = 0;
        for(int i =0;i<k;i++){
            sum += arr[i];
        }
        if(sum >= temp){
            count++;
        }
        for(int i =k;i<arr.length;i++){
            sum = sum - arr[i-k]+arr[i];
            if(sum >= temp){
                count++;
            }
        }
        return count;
    }
}
